<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo Yii::$app->name;?> 后台管理</title>
<?php $this->HeaderView(['datetimepicker']);?>

<script>
function view(postid){
    var url = '<?php echo $this->createUrl('view')?>?postid='+postid;	
	art.dialog.open(url,{
		id:'view',
		width:480,
		lock:true,
		fixed:true,
		title:'帖子详情'
	});
}

</script>
</head>
<body class="view_index" id="view_index_Article">
<div class="view-index-nav">
        <h3>帖子管理</h3>
  <p class="tips">
        <strong style="color:#F00">屏蔽</strong>的帖子在前台只有版主可见。
        </p>
</div>


<form class="view-index-form" style="margin:0px 20px" method="POST" action="<?php echo $this->createUrl(['models-form/index', 'modelid'=>$modelid]);?>" enctype="multipart/form-data">
<table class="view-index-search mb-10" border="0" cellspacing="0" cellpadding="0" width="100%">
<?=$this->csrfToken()?>
        <tr>
        <td class="search">
        <div class="div-search" style="margin:0px 0px">
        <div class="ftr">
        <button class="ui-btn ui-btn-primary mb-10" type="button" onclick="href('<?php echo $this->createUrl(['models-form/create', 'modelid'=>$modelid]);?>')"><span class="icon-plus">+</span>添加内容</button>
        
        
        </div>
       <input placeholder="请输入关键字" class="input-keyword" value="<?php echo $search['keyword'];?>" name="keyword" id="kw" style="width:200px;"/>
       <input placeholder="开始时间" class="input-keyword" value="<?php echo @$search['starttime'];?>" name="starttime" id="starttime" style="width:70px;"/> ~ <input placeholder="结束时间" class="input-keyword" value="<?php echo @$search['endtime'];?>" name="endtime" id="endtime" style="width:70px;"/><input id="submit_search" class="button-submit" type="submit" value="搜 索" name="submit_search" />
        <span class="view-index-batch">
        
        </span></div>
         
        </td>
        </tr>
</table>
</form>
<form class="view-index-form" method="post" action="<?php echo $this->createUrl(['models-form/batch']);?>" enctype="multipart/form-data">
<input type="hidden" value="<?php echo $modelid;?>" name="modelid" id="modelid"/>
<table class="view-index-list" style="margin-top:0; margin-bottom:0" border="0" cellspacing="0" cellpadding="0" width="100%">

    <thead>
        <tr>
                        <th align="left" width="20"><input type="checkbox" class="button-checkbox" value="全选"  name="checked_id[]" id="chkall" onclick="checkAll(this, 'checked_id[]');"></th>
                        <th align="left" width="50">序号<a style="display:inline-block;" href="<?php echo $this->createUrl(array_merge($_GET, array('models-form/index', 'orderby'=> $orderby[0] == $models['primarykey'] && $orderby[1]=='desc' ? "a.`{$models['primarykey']}` asc" : "a.`{$models['primarykey']}` desc")));?>"><span class="icon-order <?php echo $orderby[1];?>"></span></a></th>
                        <?php
						$tableName = $models['models']['tablename'];
                        $class = 'submodule_'.$tableName;
                        $sFile = "../runtime/submodule_save/$class.php";
                        require($sFile);
                        
                        $function = new $class($models, [], $modelid);
				        foreach($indexFields as $k=>$val){

						
		                if ($val['field'] == 'listorder'){?>	
                        <th align="left" width="40"><?php echo $val['name']?></th>
                        <?php
						}else if ($val['field'] == 'status'){?>
                        <th align="center" width="50"><?php echo $val['name']?></th>
                        <?php
						}else{
						?>
                        <th align="left" <?php echo $models['models']['setting']['index']['th'][$val['fieldid']]?>><?php echo $val['name']?>
                        <a style="display:inline-block;" href="<?php echo $this->createOrderbyUrl($val, $orderby);?>"><span class="icon-order <?php echo str_replace(['a.','b.'], '', $orderby[0])== $val['field'] ? $orderby[1] : '';?>"></span></a>

                        </th>
                        <?php
						}
						}
						?>
                        
                        
                        
                        <th class="norightborder" width="50">操作</th>
        </tr>
    </thead>
    <tbody>
   <?php  
    foreach($rows as $k=>$v){
    ?>
    <tr>
        <td align="center"><input type="checkbox" class="button-checkbox" value="<?php echo $v[$models['primarykey']];?>" name="checked_id[]"/></td>
        <td><?php echo $v[$models['primarykey']];?></td> 
        <?php			
		foreach($indexFields as $kk=>$val){
		?>
        <?php
		if ($val['field'] == 'listorder'){?>
        <td><input class="input-text input-listorder" value="<?php echo $v['listorder'];?>" name="listorder[<?php echo $v['id'];?>]"></td>
        <?php
		}else if ($val['field'] == 'status'){
		?>
        <td class="td-locked"><div onclick="change_switch(this, '<?php echo $this->createUrl(['models-form/status', 'modelid'=>$modelid, 'field'=>'status', 'id'=>$v[$models['primarykey']], 'status'=>'-status-']);?>');" id="btn-locked" class="locked-<?php echo intval($v['status']);?>"></div></td> 
         <?php
		 }else if ($val['field'] == 'addtime' || $val['field'] == 'updatetime'){
		?>
        <td><?php echo date('Y-m-d', $v[$val['field']]);?></td> 
         <?php
		}else{
		?>
        <td><?php echo $this->indexFieldsValues($models, $val, $v, $function);?></td>
        <?php
		}
		}
		?>
        
           <td class="td-operation">
             <a href="<?php echo $this->createUrl(['models-form/update', 'modelid'=>$modelid, 'id'=> $v[$models['primarykey']]])?>" class="operation-update"></a>
             
             <a href="<?php echo $this->createUrl(['models-form/delete', 'modelid'=>$modelid, 'id'=>$v[$models['primarykey']]])?>" title="确定要删除吗？<br><br>删除后将无法恢复。" class="ml-5 operation-delete"></a>
            </td>
    </tr>
    <?php
	}
	?>
</tr>  
        
        
        </tbody>
    
</table>
<table class="view-index-list" style="margin-top:0; border-top:0" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr style="background-color:#eee" class="batch">
<td width="300">
<input type="button" class="button-submit ml-5" value="全选" name="chkall" id="chkall" onclick="checkAll(this, 'checked_id[]');"><input type="button" class="button-submit button-reverse" value="反选" name="chkall" id="chkall" onclick="checkReverse(this, 'checked_id[]');">

<input id="batch_delete" class="button-submit ml-5" type="submit" value="批量删除" name="batch_delete" onclick="return confirm_delete('checked_id[]', this);">

<input id="submit_search" class="button-submit ml-5" type="submit" value="排序" name="batch_listorder">
<td align="right">
<div class="pages ftr">
<?=$this->linkPager($pages)?>
</div>
</td>
</td>
</tr>  
        
        
        </tbody>
    
</table>
<?=$this->csrfToken()?>
</form>

<script>
$(function(){
    $('#starttime,#endtime').datetimepicker({lang:'ch', step:1, format:'Y-m-d', allowBlank:true});
});
</script>



<?php $this->FooterView();?>
</body>
</html>